using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class alert_itemMap : EntityTypeConfiguration<alert_item>
    {
        public alert_itemMap()
        {
            // Primary Key
            this.HasKey(t => t.alert_item_id);

            // Properties
            this.Property(t => t.alert_item_name)
                .IsRequired()
                .HasMaxLength(80);

            this.Property(t => t.alert_desc)
                .HasMaxLength(200);

            // Table & Column Mappings
            this.ToTable("alert_item");
            this.Property(t => t.alert_item_id).HasColumnName("alert_item_id");
            this.Property(t => t.alert_item_name).HasColumnName("alert_item_name");
            this.Property(t => t.alert_desc).HasColumnName("alert_desc");
            this.Property(t => t.role_id).HasColumnName("role_id");

            // Relationships
            this.HasOptional(t => t.role)
                .WithMany(t => t.alert_item)
                .HasForeignKey(d => d.role_id);

        }
    }
}
